package com.huawo.qjs.widgets;

import android.graphics.Point;
import android.util.Size;

import com.huawo.qjs.QjsDependence;
import com.huawo.qjs.QjsWidget;

import java.util.ArrayList;
import java.util.List;

public class QjsDuration extends QjsWidget {

    public QjsDuration(String name) {
        super(name);
    }

    /**
     * 控件名称（英文字母开头，全局唯一即可，不要太长）
     *
     * @param name  英文字母开头，全局唯一即可，不要太长
     * @param color 控件颜色
     */
    public QjsDuration(String name, int color) {
        super(name);
        this.setColor(color);
    }

    private Point imgPoint;

    @Override
    public List<String> getImageNames() {
        List<String> list = new ArrayList<>();
        list.add("data_num_2d_g");
        list.add("data_num_30_g");
        list.add("data_num_31_g");
        list.add("data_num_32_g");
        list.add("data_num_33_g");
        list.add("data_num_34_g");
        list.add("data_num_35_g");
        list.add("data_num_36_g");
        list.add("data_num_37_g");
        list.add("data_num_38_g");
        list.add("data_num_39_g");
//        list.add("data_num_2103_g");
//        list.add("data_num_2109_g");
        list.add("icon_time");
        return list;
    }

    @Override
    public List<QjsDependence> getDependences() {
        List<QjsDependence> dependences = new ArrayList<>();
        dependences.add(new QjsDependence("label", "label.js"));
        dependences.add(new QjsDependence("img", "img.js"));
        return dependences;
    }

    @Override
    public String start() {
        String numPath = "data_num_";
        numPath = numPath + getColor() + "_";
        String str = groupJS("_dur", ACTIVITY_TIME, numPath, getLocation(), getSize(), getStyle(), index);

        String iconPath = "icon_time";
        iconPath = iconPath + "_" + getColor();
        iconPath = iconPath + ".bin";

        String imgStr = imgJS("_dur", iconPath, imgPoint, index);
        return str + imgStr;
    }

    public String Resume() {
        String numPath = "data_num_";
        numPath += getColor() + "_";
        return groupResumeJs("_dur", ACTIVITY_TIME, numPath, getLocation(), getSize(), getStyle(), index);
    }

    @Override
    public Point getImgPoint() {
        return imgPoint;
    }

    @Override
    public void setImgPoint(Point imgPoint) {
        this.imgPoint = imgPoint;
        setSize(new Size(100, 26));
//        setLocation(new Point(imgPoint.x - getSize().getWidth(), imgPoint.y + 7));
        setLocation(new Point(imgPoint.x, imgPoint.y));
    }
}
